package com.treehouse.logging;

import java.io.PrintStream;
import java.util.LinkedList;

public class Logger {

	public static PrintStream inf = System.out;
	public static PrintStream err = System.err;
	private static LinkedList<ILoggingListener> listener = new LinkedList<ILoggingListener>();
	
	private Logger() {
		
	}
	
	public static void addListener(ILoggingListener listener){
		Logger.listener.add(listener);
	}
	
	public static void removeListener(ILoggingListener listener){
		Logger.listener.remove(listener);
	}
	
	public static void inf(String message) {
		Logger.inf.println("[INFO] " + message);
		for(ILoggingListener l : Logger.listener){
			l.inf(message);
		}
	}
	
	public static void err(String message) {
		Logger.err.println("[ERROR] " + message);
		for(ILoggingListener l : Logger.listener){
			l.err(message);
		}
	}
}
